﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Component;

public partial class BackEnd_LienHeModify : System.Web.UI.UserControl
{
    public string _Url = "";
    public string _idCat = "";
    LienHeInfo info;
    public string _parent = "";
    public string _Session = "";
    //string _UrlCateSub = BackEndQuery._AdminQuery + BackEndQuery._LienHeS + "&" + ConstString._RParent + ConstString._dauBang;
    public string[] ds1 = new string[] { "Danh mục con", "Sản phẩm" };
    public string[] ds2 = new string[] { "Danh mục con", "Tin tức" };
    protected void Page_Load(object sender, EventArgs e)
    {
        _idCat = Request.QueryString[ConstString._idcat] ?? "";

        _Url = "<a href=\"" + BackEndQuery._AdminQuery + BackEndQuery._LienHeL + "\"> Danh sách danh mục" + "</a>";

        if (_idCat != "")
            Load_Data();

    }
    private void Load_Data()
    {
        info = LienHeDB.GetById(int.Parse(_idCat));
        txtName.Text = info.Name;
        txtAdress.Text = info.Adress;
        txtContent.Value = info.Content;
        txtEmail.Text = info.Email;
        txtPhone.Text = info.Phone;
    }

    protected void cmdLuu_Click(object sender, EventArgs e)
    {
        info = new LienHeInfo();
        info.Name = txtName.Text;
        info.Adress = txtAdress.Text;
        info.Content = txtContent.Value;
        info.Email = txtEmail.Text;
        info.Title = txtTitle.Text;
        info.Phone = txtPhone.Text;
        if (_idCat == "")
        {
            if (LienHeDB.Insert(info))
                lbMessage.Text = ConstString._themTC;
            else
                lbMessage.Text = ConstString._themTB;
        }
        else
        {
            if (LienHeDB.Update(info))
                lbMessage.Text = ConstString._capNhatTC;
            else
                lbMessage.Text = ConstString._capNhatTB;
        }
    }
}
